
#include "testCompressObject.h"

CPPUNIT_TEST_SUITE_REGISTRATION (testCompressObject);

void testCompressObject :: setUp (void){
}

void testCompressObject :: tearDown (void) {
	if(obj) delete obj;
}

void testCompressObject :: testGetCompressType (void)
{
	obj = new compressObject("rc4");
	CPPUNIT_ASSERT_EQUAL ((string)"rc4", obj->getType());
}

void testCompressObject :: testIsValidCompressObject (void) {
	obj = new compressObject("");
	CPPUNIT_ASSERT_EQUAL (false, obj->isValid());
	delete obj;
	obj = new compressObject("rc4");
	CPPUNIT_ASSERT_EQUAL (true, obj->isValid());
}

void testCompressObject :: testGet20Bytes (void) {
	obj = new compressObject("rc4");
	CPPUNIT_ASSERT_EQUAL (20, (int)obj->get20byte("").length());
	CPPUNIT_ASSERT_EQUAL (0, (int)staticObject::trim(obj->get20byte("")).length());
	CPPUNIT_ASSERT_EQUAL (20, (int)obj->get20byte("- 10byte -").length());
	CPPUNIT_ASSERT_EQUAL (10, (int)staticObject::trim(obj->get20byte("- 10byte -")).length());
}

void testCompressObject :: testPerformCompress (void)
{
	obj = new compressObject("rc4");
	std::string content = "Dieser Text soll compressed werden";
	std::string compressContent = obj->performCompress(content);
	std::string clearContent = obj->performDeCompress(compressContent);

	CPPUNIT_ASSERT_EQUAL (content, clearContent);
}

void testCompressObject :: testPerformCompressWithFile (void)
{
	obj = new compressObject("rc4");
	std::string content = staticObject::loadFromFile("res/testCompressObject_clear");
	std::string compressContent = obj->performCompress(content);
	std::string clearContent = obj->performDeCompress(compressContent);

	CPPUNIT_ASSERT_EQUAL (content, clearContent);
}

